// ts中对象相当于一个属性模板，对象定义后不能添加属性

let myObj = {
    name: "Hydra",
    word: "Hello",
    sayHello(word:string):void {
        console.log(`${this.name}说：“${word}”`);
    }
}

// 错误
// myObj.sex = "男"

// 可以把对象作为数据类型模板，用于定义函数的参数
function sayHello(obj:{name:string,word:string,sayHello: (word:string)=>void}):void {
    obj.sayHello(obj.word);
}

sayHello(myObj);
sayHello({name: "奉先",word: "你好",sayHello(word:string): void {
    console.log("你好");
}})